// let DDZ = require('./ddz');
// let Player = require('./player');
let Card = require('./card.js');
let AI = require('./ai.js');
let Poker = require('./poker.js');
let utils = require('./utils.js');

// let game = new DDZ(1);
// let p1 = new Player(1);
// let p2 = new Player(2);
// let p3 = new Player(3);

// game.start(p1,p2,p3,function(){
// 	console.log('-------------stard-------------\n');
//     let player = this.getPlayer(0);
//     let cards = player.getAllCards();
//     let ai = new AI(cards);
//     ai.analyze();
// });

let poker = new Poker();

let cs = poker.deal();
// let handCards = cs[1]; 

let ai = new AI(1);   
let lastInfo = Card.parseCardType([new Card(16)]);
lastInfo.dz = 0;

let  handCards = [];
handCards.push(new Card(10));
handCards.push(new Card(11));
handCards.push(new Card(12));
handCards.push(new Card(9));
handCards.push(new Card(8));
handCards.push(new Card(15));
handCards.push(new Card(15));
handCards.push(new Card(26));
handCards.push(new Card(17));
handCards.push(new Card(28));
handCards.push(new Card(29));
handCards.push(new Card(20));
handCards.push(new Card(5));
handCards.push(new Card(2));
handCards.push(new Card(23));

handCards.sort(function (a, b) {
    if (a.getValue() < b.getValue()) return -1;
    else return 1;
})
console.log(handCards);
console.log(lastInfo);

let cCards= utils.classify(handCards);
console.log(cCards);
let cards = ai.autoPlay(lastInfo,handCards);
console.log(cards)

/*
 1, 分牌. 将手上的牌拆开, 可能形成多个结果
 2, 跟牌, 如果有多个选项, 需要选择评分最高的那个.
 评分算法, 影响评分结果的因素: 手数, 收牌(出牌后,能否保证下一轮出牌时还能要得起)
 如果不能收牌,考虑配合下家. 
 配合算法: 让下家出牌.
 */

// function test() { return 123123; }
// let x = test() || "afsdfasdf";
// console.log(x);

// let ls = [];
// ls.push(new Card(0));
// ls.push(new Card(1));
// ls.push(new Card(2));
// ls.push(new Card(3));
// ls.push(new Card(4));
// ls.push(new Card(5));
// ls.push(new Card(5));
// ls.push(new Card(6));
// ls.push(new Card(7));
// ls.push(new Card(8));
// ls.push(new Card(9));
// ls.push(new Card(10));
// ls.push(new Card(11));
// ls.push(new Card(12));
// ls.push(new Card(13));
// ls.push(new Card(14));
// ls.sort(function (a, b) {
//     if (a.getValue() < b.getValue()) return -1;
//     else return 1;
// })
// let info = utils.getSequence(ls);
// console.log('seq:', info.seq);
// let info2 = utils.classify(ls);
// console.log('group:', info2.group);
